import React from 'react';
import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { Button, Checkbox, Form, Input } from 'antd';
import { loginFn } from '@/api/user';
import './index.less'
const App: React.FC = () => {
    const onFinish = (values: any) => {
        // console.log('Received values of form: ', values);
        loginFn(values).then(res => {
            console.log(res.data.data);
            // 将登录之后的数据保存在 dva 全局状态管理中
            localStorage.setItem('token', res.data.data.token)
            // 跳转到首页

        })

    };

    return (
        <Form
            name="normal_login"
            className="login-form"
            initialValues={{ remember: true }}
            onFinish={onFinish}
        >
            <Form.Item
                name="adminname"
                rules={[{ required: true, message: '用户名不能为空!' }]}
            >
                <Input prefix={<UserOutlined className="site-form-item-icon" />} placeholder="请输入用户名" />
            </Form.Item>
            <Form.Item
                name="password"
                rules={[{ required: true, message: '密码不能为空!' }]}
            >
                <Input
                    prefix={<LockOutlined className="site-form-item-icon" />}
                    type="password"
                    placeholder="请输入密码"
                />
            </Form.Item>
            <Form.Item>
                <Form.Item name="remember" valuePropName="checked" noStyle>
                    <Checkbox>记住我</Checkbox>
                </Form.Item>

                <a className="login-form-forgot" href="">
                    忘记密码
                </a>
            </Form.Item>

            <Form.Item>
                <Button type="primary" htmlType="submit" className="login-form-button">
                    登录
                </Button>
                <a href="">去注册!</a>
            </Form.Item>
        </Form>
    );
};

export default App;